package com.zh.chat.entity;


/**
 * 服务器与客户端之间的的命令协议
 * 
 * @author tom
 */
public class UDPProtocol {
	public static final int RESP_KEEP_ONLINE =				0;//客户端保持在线|服务器确认在线
	public static final int REQ_SEND_MSG	=				1;//发送消息给某用户
	public static final int REQ_FRIENDS_LIST =				2;//请求好友列表
	public static final int REQ_FRIEND_MATERIAL =			3;//请求某个好友资料
	public static final int REQ_MODIFY_PASSWORD = 			4;//请求修改某ID密码
	public static final int REQ_MODIFY_MATERIAL =			5;//请求修改用户资料
	public static final int REQ_MODIFY_FRIEND_DIVIDED = 	6;//修改某个好友的分组
	public static final int REQ_ADD_FRIEND =				7;//增加好友到某个分组
	public static final int REQ_DEL_FRIEND =				8;//删除好友
	public static final int REQ_LOGIN =						9;//用户登陆
	public static final int REQ_LOGOUT =					10;//用户登出
	public static final int REQ_CHANGE_STATUS =				11;//用户改变状态
	public static final int REQ_USERINFO =					12;//请求用户资料
	public static final int REQ_IP =						13;//用户请求IP
	public static final int REQ_RECIVE_FILE = 				14;//请求对方开始接收文件
	public static final int REQ_RECIVE_VOICE = 				15;//请求服务器与好友建立语音连接
	public static final int REQ_MODIFY_PROFILE =			21;//更新用户头像
	public static final int REQ_REGIST =					22;//用户注册
	public static final int REQ_SEND_FILE =					23;//向服务器发送文件
	public static final int RESP_SEND_FILE_ACK =			24;//响应服务器或客户端-已准备好
	
	public static final int REQ_KEEP_ONLINE =				100;//服务器回应保持在线
	public static final int RESP_SEND_MSG =					101;//服务器转发聊天信息同时给聊天两方
	public static final int RESP_FRIENDS_LIST =				102;//返回所有好友列表
	public static final int RESP_FRIEND_MATERIAL =			103;//返回某个好友信息
	public static final int RESP_MODIFY_PASSWORD =			104;//返回修改密码结果
	public static final int RESP_MODIFY_MATERIAL =			105;//返回修改结果
	public static final int RESP_MODIFY_FRIEND_DIVIDED =	106;//返回修改好友分组结果
	public static final int RESP_ADD_FRIEND =				107;//返回添加好友结果
	public static final int RESP_DEL_FRIEND =				108;//返回删除好友结果
	public static final int RESP_LOGIN =					109;//返回用户登陆结果
	public static final int RESP_LOGOUT =					110;//返回用户登出结果
	public static final int RESP_CHANGE_STATUS =			111;//返回用户改变状态结果
	public static final int RESP_USERINFO =					112;//请求用户资料
	public static final int RESP_IP =						113;//回复用户请求IP
	public static final int RESP_RECIVE_FILE = 				114;//确认请求开始接收文件
	public static final int RESP_RECIVE_VOICE = 			115;//服务器返回确认建立语音连接信息
	public static final int RESP_MODIFY_PROFILE =			121;//更新用户头像
	public static final int RESP_REGIST =					122;//返回用户注册
	public static final int REQ_SERVER_SEND_FILE =			123;//向客户端发送文件
	public static final int RESP_SERVER_SEND_FILE_ACK = 	124;//响应客户端-已准备好
	public static final int RESP_SERVER_BUSSY =				199;//服务器正在维护
	
	private int code; // 命令的识别号
	private String clientIp; // 客户端IP
	private int clientPort; // 客户端命令端口
	private int serverPort;//服务器命令端口
	private String serverIp;//服务器IP
	private int clientFilePort;//接收图片的端口
	private int serverFilePort;
	private Long requestId;//这条命令的创造者id
	private Long targetId;//这条命令的目的地id
	private String clazz;
	private Object data; // 数据
	private Long sendTime;//消息发送的时间
	private Long reciveTime;//消息发送的时间
	
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getClientIp() {
		return clientIp;
	}

	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}

	public int getClientPort() {
		return clientPort;
	}

	public void setClientPort(int clientPort) {
		this.clientPort = clientPort;
	}

	public int getServerPort() {
		return serverPort;
	}

	public void setServerPort(int serverPort) {
		this.serverPort = serverPort;
	}

	public String getServerIp() {
		return serverIp;
	}

	public void setServerIp(String serverIp) {
		this.serverIp = serverIp;
	}

	public int getClientFilePort() {
		return clientFilePort;
	}

	public void setClientFilePort(int clientFilePort) {
		this.clientFilePort = clientFilePort;
	}

	public int getServerFilePort() {
		return serverFilePort;
	}

	public void setServerFilePort(int serverFilePort) {
		this.serverFilePort = serverFilePort;
	}
	
	public Long getRequestId() {
		return requestId;
	}

	public void setRequestId(Long requestId) {
		this.requestId = requestId;
	}

	public Long getTargetId() {
		return targetId;
	}

	public void setTargetId(Long targetId) {
		this.targetId = targetId;
	}

	public String getClazz() {
		return clazz;
	}

	public void setClazz(String clazz) {
		this.clazz = clazz;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	public Long getSendTime() {
		return sendTime;
	}

	public void setSendTime(Long sendTime) {
		this.sendTime = sendTime;
	}

	public Long getReciveTime() {
		return reciveTime;
	}

	public void setReciveTime(Long reciveTime) {
		this.reciveTime = reciveTime;
	}

	public String toString() {
		String str = null;
		if(data instanceof String){
			str = (String) data;
		}
		return "code:"+code + "\n"+
				"clientIp:"+clientIp+"\n" +
				"clientPort:" + clientPort + "\n" +
				"serverPort:" + serverPort +"\n" +
				"serverIp:" + serverIp +"\n"+
				"clientFilePort:" + clientFilePort+"\n"+
				"serverFilePort:" +serverFilePort + "\n"+
				"requestId:" + requestId+"\n"+
				"targetId:" + targetId+"\n"+
				"sendTime:"+sendTime+"\n"+
				"data:" + (str==null?"非字符串":str);
	}
}